package org.example.gradleDemo.jmh;

import java.util.*;

public class HashMapJmh {

    HashMap<Long, Trade> _map = new HashMap<>();

    public final void put(final Trade trade) {
        _map.put(trade.id(), trade);
    }

    public final Trade GetSecondPrice() {
        List<Trade> list = new ArrayList<>(_map.values());
        list.sort(Comparator.comparing(Trade::price));
        return list.size() >= 2 ? list.get(1) : null;
    }
}
